package com.sls.mall.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;

//@Data
public class OrderConfirmVo {

    @Getter @Setter
    List<MemberAddressVo> address;

    @Getter @Setter
    List<OrderItemVo> items;

    @Getter @Setter
    Integer integration;
    @Getter @Setter
    String orderToken;

//    BigDecimal totalAmount;

    public BigDecimal getTotalAmount() {
        BigDecimal total = new BigDecimal("0");
        if(items != null){
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount()));
                total = total.add(multiply);
            }
        }
        return total;
    }

//    BigDecimal payAmount;

    public BigDecimal getPayAmount() {
        return getTotalAmount();
    }

    public Integer getTotalCount() {
        int count = 0;
        if(items != null){
            for (OrderItemVo item : items) {
                count = count+item.getCount();
            }
        }
        return count;
    }
}
